package com.teknova.usctest;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

import android.content.Context;
import android.os.Handler;

/**
 * <tt>Thread for clocking</tt>
 * @author Fate.AKong
 */
public class TimerThread extends Thread {

	private Handler hdl;

	public TimerThread (Context ct) {
		hdl = ((UltrasoundClientTestActivity)ct).hdlUI;
	}

	/* (non-Javadoc)
	 * @see java.lang.Thread#run()
	 */
	@Override
	public void run() {
		super.run();
		SimpleDateFormat fmt = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss");
//		DateFormat fmt = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.LONG);
		while(true) {
			hdl.obtainMessage(1, fmt.format(new Date())).sendToTarget();
			try {
				Thread.sleep(1000);
			} catch (InterruptedException e) {
			}
		}
	}
}
